package com.qs.education.bean.api;

import java.util.List;

/**
 * 分页工具类
 * @author Arwen Liu
 * @param <T>
 * @date 2018-11-08
 */
@SuppressWarnings("rawtypes")
public class  PageBean extends ResponseBean{
	private  List list ; 
	private int currentPage; 
	private int pageCount;
	private int pageSize;
	private int recordCount; 
	private int beginPageIndex;
	private int endPageIndex;
	
	public PageBean() {
		//new PageBean(pageSize, currentPage, recordCount, list);
	}
	
	/**
	 * 
	 * @param pageSize 每页显示记录数
	 * @param currentPage 当前页
	 * @param recordCount 总记录数
	 * @param list 查询信息List集合
	 */
	public PageBean(int currentPage,int pageSize,int recordCount, List list) {
		this.pageSize = pageSize;
		this.currentPage = currentPage;
		this.recordCount = recordCount;
		this.list = list;
		pageCount = (recordCount + pageSize -1) / pageSize;
		if(pageCount <= 10){
			beginPageIndex = 1;
			endPageIndex = pageCount;
			if(endPageIndex == 0){
				endPageIndex = 1;
			}
			
		}else if(pageCount > 10){
			// 前4页+当前页+后5页（共十页）
			beginPageIndex = currentPage - 4;
			endPageIndex = currentPage + 5;
			// 当前页前面不够4页
			if(beginPageIndex < 1){
				beginPageIndex = 1;
				endPageIndex = 10;
			}
			//当前页后面不够5页
			if(endPageIndex > pageCount){
				endPageIndex = pageCount;
				beginPageIndex = pageCount - 9 ;
			}
		}
		
	}
	
	
	
	
	public List getList() {
		return list;
	}
	public void setList(List list) {
		this.list = list;
	}

	public int getCurrentPage() {
		return currentPage;
	}
	public void setCurrentPage(int currentPage) {
		this.currentPage = currentPage;
	}
	public int getPageCount() {
		return pageCount;
	}
	public void setPageCount(int pageCount) {
		this.pageCount = pageCount;
	}
	public int getPageSize() {
		return pageSize;
	}
	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}
	public int getRecordCount() {
		return recordCount;
	}
	public void setRecordCount(int recordCount) {
		this.recordCount = recordCount;
	}
	public int getBeginPageIndex() {
		return beginPageIndex;
	}
	public void setBeginPageIndex(int beginPageIndex) {
		this.beginPageIndex = beginPageIndex;
	}
	public int getEndPageIndex() {
		return endPageIndex;
	}
	public void setEndPageIndex(int endPageIndex) {
		this.endPageIndex = endPageIndex;
	}
	
	
	
	
	
}
